package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceReasonrefuse;
import com.ruoyi.service.service.IServiceReasonrefuseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 拒单转介原因Controller
 * 
 * @author ZDL
 * @date 2024-12-26
 */
@RestController
@RequestMapping("/service/reasonrefuse")
public class ServiceReasonrefuseController extends BaseController
{
    @Autowired
    private IServiceReasonrefuseService serviceReasonrefuseService;

    /**
     * 查询拒单转介原因列表
     */
    @PreAuthorize("@ss.hasPermi('service:reasonrefuse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceReasonrefuse serviceReasonrefuse)
    {
        startPage();
        List<ServiceReasonrefuse> list = serviceReasonrefuseService.selectServiceReasonrefuseList(serviceReasonrefuse);
        return getDataTable(list);
    }

    /**
     * 导出拒单转介原因列表
     */
    @PreAuthorize("@ss.hasPermi('service:reasonrefuse:export')")
    @Log(title = "拒单转介原因", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceReasonrefuse serviceReasonrefuse)
    {
        List<ServiceReasonrefuse> list = serviceReasonrefuseService.selectServiceReasonrefuseList(serviceReasonrefuse);
        ExcelUtil<ServiceReasonrefuse> util = new ExcelUtil<ServiceReasonrefuse>(ServiceReasonrefuse.class);
        util.exportExcel(response, list, "拒单转介原因数据");
    }

    /**
     * 获取拒单转介原因详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:reasonrefuse:query')")
    @GetMapping(value = "/{reasonrefuseId}")
    public AjaxResult getInfo(@PathVariable("reasonrefuseId") Long reasonrefuseId)
    {
        return success(serviceReasonrefuseService.selectServiceReasonrefuseByReasonrefuseId(reasonrefuseId));
    }

    /**
     * 新增拒单转介原因
     */
    @PreAuthorize("@ss.hasPermi('service:reasonrefuse:add')")
    @Log(title = "拒单转介原因", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceReasonrefuse serviceReasonrefuse)
    {
        return toAjax(serviceReasonrefuseService.insertServiceReasonrefuse(serviceReasonrefuse));
    }

    /**
     * 修改拒单转介原因
     */
    @PreAuthorize("@ss.hasPermi('service:reasonrefuse:edit')")
    @Log(title = "拒单转介原因", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceReasonrefuse serviceReasonrefuse)
    {
        return toAjax(serviceReasonrefuseService.updateServiceReasonrefuse(serviceReasonrefuse));
    }

    /**
     * 删除拒单转介原因
     */
    @PreAuthorize("@ss.hasPermi('service:reasonrefuse:remove')")
    @Log(title = "拒单转介原因", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reasonrefuseIds}")
    public AjaxResult remove(@PathVariable Long[] reasonrefuseIds)
    {
        return toAjax(serviceReasonrefuseService.deleteServiceReasonrefuseByReasonrefuseIds(reasonrefuseIds));
    }
}
